<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { IconSelect } from "@/components/ReIcon";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    path: "",
    title: "",
    icon: "",
    rank: 1
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <div>
    <el-form
      ref="ruleFormRef"
      :model="newFormInline"
      :rules="formRules"
      label-width="120px"
    >
      <el-row :gutter="30">
        <re-col :value="24" :xs="24" :sm="24">
          <el-form-item label="目录名称:" prop="title">
            <el-input
              v-model="newFormInline.title"
              clearable
              placeholder="请输入"
            />
          </el-form-item>
        </re-col>
        <re-col :value="24" :xs="24" :sm="24">
          <el-form-item label="路由标识:" prop="path">
            <el-input
              v-model="newFormInline.path"
              clearable
              placeholder="请输入"
            />
          </el-form-item>
        </re-col>
        <re-col :value="24" :xs="24" :sm="24">
          <el-form-item label="图标:" prop="icon">
            <IconSelect v-model="newFormInline.icon" class="w-full" />
          </el-form-item>
        </re-col>
        <re-col :value="24" :xs="24" :sm="24">
          <el-form-item label="排序:" prop="rank">
            <el-input
              type="number"
              v-model="newFormInline.rank"
              clearable
              placeholder="请输入"
            />
          </el-form-item>
        </re-col>
      </el-row>
    </el-form>
  </div>
</template>

<style lang="scss" scoped>
:deep(.readonlyInput .el-input__wrapper) {
  background-color: #efefef;
}
:deep(.readonlyInput .el-input__inner) {
  cursor: pointer;
}
</style>
